<template>
  <j-modal title="填写取消信息" :width="600" :visible="visible" :confirmLoading="loading" switchFullscreen
    @cancel="handleCancel" @ok="handleOk">
    <a-form-model ref="ruleForm" :rules="rules" :model="form" :label-col="{ span: 4 }" :wrapper-col="{ span: 18 }">
      <a-form-model-item label="取消原因" prop="cancelReason">
        <a-select v-model="form.cancelReason" placeholder="请选择">
          <a-select-option value="1">对方拒访</a-select-option>
          <a-select-option value="2">个人原因</a-select-option>
          <a-select-option value="3">其他</a-select-option>
        </a-select>
      </a-form-model-item>
      <a-form-model-item label="原因说明" prop="cancelReasonExplain">
        <a-textarea v-model="form.cancelReasonExplain" placeholder="请输入" :auto-size="{ minRows: 4, maxRows: 6 }" />
      </a-form-model-item>
      <a-form-model-item label="附件">
        <j-upload v-model="form.cancelFile" :number="1"></j-upload>
        <p>支持扩展名：.rar .zip .doc .docx .pdf .jpg...</p>
      </a-form-model-item>

    </a-form-model>
  </j-modal>
</template>
<script>
import * as interviewApi from '@/api/sjsk/help/interview.js'
export default {
  name: 'CancelModal',
  data() {
    return {
      visible: false,
      form: {},
      rules: {
        cancelReason: [{ required: true, message: '请选择' }],
        cancelReasonExplain: [{ required: true, message: '请输入' }],
      },
      loading:false
    }
  },
  async created() {
  },
  methods: {
    show(record) {
      this.visible = true
      this.form = {}
      this.form.id = record.id
    },
    handleCancel() {
      this.visible = false
    },
    handleOk() {
      this.$refs.ruleForm.validate((valid) => {
        if (valid) {
          this.loading = true
          interviewApi.cancelInterviewRecord(this.form).then(res => {
            if (res.success) {
              this.$message.success(res.message)
              this.$emit('ok');
              this.visible = false
              this.loading = false
            } else {
              this.loading = false
              this.$message.warn(res.message)
            }
          })
            .catch(e => {
              this.loading = false
              this.$message.warn('请求失败！')
            })
        }
      })
    },
  },
}
</script>
<style lang="less" scoped>

</style>
